<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('事件同步列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>事件ID：</label>
                                <input type="text" name="workId"/>
                            </li>
                            <li>
                                <label>用户标识：</label>
                                <input type="text" name="userId"/>
                            </li>
                            <li>
                                <label>设备标识：</label>
                                <input type="text" name="deviceId"/>
                            </li>
                            <li>
                                <label>三方ID：</label>
                                <input type="text" name="unionId"/>
                            </li>
                            <li>
                                <label>应用：</label>
                                <select name="productId" id="productId">
                                    <option value="">请选择应用</option>
                                    <option th:each="product:${productList}" th:text="${product.name}" th:value="${product.id}"></option>
                                </select>
                            </li>
                            <li>
                                开始时间：
                                <input type="text" class="time-input" placeholder="请选择开始时间" id="startCreateTime" name="startCreateTime" th:value="${#dates.format(startCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                截止时间：
                                <input type="text" class="time-input" placeholder="请选择结束时间" id="endCreateTime" name="endCreateTime" th:value="${#dates.format(endCreateTime, 'yyyy-MM-dd')}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="privateReset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>


            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('product:work:edit')}]];
        var removeFlag = [[${@permission.hasPermi('product:work:remove')}]];
        var prefix = ctx + "product/work";
        window.onload = function() {
            timeInit();
        }
        function timeInit() {
            var dateEnd = new Date();
            var dateStart = $.common.get7DaysBefore(dateEnd);
            var dateEndStr = $.common.dateFormat(dateEnd, "yyyy-MM-dd");
            var dateStartStr = $.common.dateFormat(dateStart, "yyyy-MM-dd");
            $('#startCreateTime').val(dateStartStr);
            $('#endCreateTime').val(dateEndStr);
        }
        function privateReset() {
            $.form.reset();
            timeInit();
        }
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/form",
                updateUrl: prefix + "/form/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "事件同步",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '${comment}',
                    visible: false
                },
                {
                    field: 'workId',
                    title: '事件ID'
                },
                {
                    field: 'userId',
                    title: '用户标识'
                },
                {
                    field: 'deviceId',
                    title: '设备标识'
                },
                {
                    field: 'unionId',
                    title: '三方ID'
                },
                {
                    field: 'productName',
                    title: '应用名称'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        if(value == 0){
                            return "进行中";
                        } else if (value == 1) {
                            return "成功";
                        } else if (value == 2) {
                            return "失败";
                        } else {
                            return "--";
                        }
                    },
                },
                {
                    field: 'failMsg',
                    title: '失败原因'
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>